# Maintainer: Rafael Ávila de Espíndola <rafael@espindo.la>
pkgname=virtiofsd
pkgver=1.12.0
pkgrel=0
pkgdesc="virtio-fs vhost-user device daemon"
url="https://gitlab.com/virtio-fs/virtiofsd"
# fails to build on 32-bit
arch="all !x86 !armhf !armv7"
license="Apache-2.0 AND BSD-3-Clause"
makedepends="
	cargo
	cargo-auditable
	libcap-ng-dev
	libseccomp-dev
	"
source="https://gitlab.com/virtio-fs/virtiofsd/-/archive/v$pkgver/virtiofsd-v$pkgver.tar.bz2"
builddir="$srcdir/virtiofsd-v$pkgver"
options="net"

# qemu doesn't ship this anymore, split to this project
provides="qemu-virtiofsd=$pkgver-r$pkgrel"
replaces="qemu-virtiofsd"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

check() {
	cargo test --frozen --release
}

package() {
	install -Dm755 target/release/virtiofsd \
		-t "$pkgdir"/usr/libexec/
	# Keep a symlink at the old install location just in case
	mkdir -p "$pkgdir"/usr/lib/qemu
	ln -s ../../libexec/virtiofsd "$pkgdir"/usr/lib/qemu

	install -Dm644 50-virtiofsd.json \
		-t "$pkgdir"/usr/share/qemu/vhost-user/
}

sha512sums="
a4c3ab90f730ff22925956a6eead89f7a35f1ed13ccd017972345141b2e7145d35ef81b50af9fb1f011bb3ee6d2990f60213e0030565b982aec0bdc8b478bfad  virtiofsd-v1.12.0.tar.bz2
"
